def quick_sort(arr):
    if len(arr) <= 1:
        return arr
    mid = arr[len(arr)//2]
    left = [x for x in arr if x < mid]
    middle = [x for x in arr if x == mid]
    right = [x for x in arr if x > mid]
    return quick_sort(left)+middle+quick_sort(right)

arr=[8,4,6,2,1,3,5,7]
print(quick_sort(arr))